package reflect;

import reflect.annotations.AutoRunMethod;
import java.lang.reflect.Method;

public class Test2 {
    public static void main(String[] args) throws Exception {
        Class cls=Class.forName("reflect.Person");
        Object o=cls.newInstance();
        Method[] methods=cls.getMethods();
        for(Method meth:methods) {
           if(meth.isAnnotationPresent(AutoRunMethod.class)
           ){
               System.out.println("执行方法"+meth.getName()+"()");
               meth.invoke(o);
            }
        }
    }
}
